package com.dotlrn.mobile;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class DotLRNNFCContextualLearningSettingsActivity extends Activity {
	
    public static final String PREFS_NAME = "MyPrefsFile";

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		
	       // Restore preferences
	       SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
	       String dotlrnURL = settings.getString("dotlrnURL", "");

		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.settings);
		final EditText platformURLEditText = (EditText) findViewById(R.id.dotlrn_url_editText);
		platformURLEditText.setText(dotlrnURL);
		final Button saveSettingsButton = (Button) findViewById(R.id.save_settings_button);
		final Button cancelButton = (Button) findViewById(R.id.cancel_button);

		saveSettingsButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {


			      // We need an Editor object to make preference changes.
			      // All objects are from android.context.Context
			      SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
			      SharedPreferences.Editor editor = settings.edit();
			      editor.putString("dotlrnURL", platformURLEditText.getText().toString());

			      // Commit the edits!
			      editor.commit();

				finish();
			}
		});

		cancelButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				finish();
			}
		});
	}

}